<template>
  <div class="admin-dashboard">
    <el-container>
      <el-aside width="200px">
        <el-menu
          :default-active="activeMenu"
          class="admin-menu"
          background-color="#304156"
          text-color="#bfcbd9"
          active-text-color="#409EFF"
          router
        >
          <el-menu-item index="/admin/dashboard">
            <i class="el-icon-s-home"></i>
            <span>仪表盘</span>
          </el-menu-item>
          <el-menu-item index="/admin/users">
            <i class="el-icon-user"></i>
            <span>用户管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/products">
            <i class="el-icon-goods"></i>
            <span>商品管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/orders">
            <i class="el-icon-tickets"></i>
            <span>订单管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/reviews">
            <i class="el-icon-chat-line-round"></i>
            <span>评论审核</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      
      <el-container>
        <el-header>
          <div class="header-right">
            <span>管理员: {{ adminName }}</span>
            <el-button type="text" @click="logout">退出登录</el-button>
          </div>
        </el-header>
        
        <el-main>
          <router-view></router-view>
          <div class="dashboard-content">
            <h2>欢迎来到管理员后台</h2>
            <p>请从左侧菜单选择管理功能</p>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { removeToken } from '@/utils/auth'

export default {
  name: 'AdminDashboard',
  data() {
    return {
      activeMenu: '/admin/dashboard',
      adminName: localStorage.getItem('adminName') || '管理员'
    }
  },
  methods: {
    logout() {
      removeToken()
      localStorage.removeItem('adminName')
      this.$router.push('/admin/login')
    }
  }
}
</script>

<style scoped>
.admin-dashboard {
  height: 100vh;
}

.el-container {
  height: 100%;
}

.el-aside {
  background-color: #304156;
}

.el-menu {
  border-right: none;
}

.el-header {
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
}

.header-right span {
  margin-right: 20px;
  color: #666;
}

.dashboard-content {
  text-align: center;
  margin-top: 100px;
}

dashboard-content h2 {
  margin-bottom: 20px;
}
</style>